-- UIPause
-- Created by zouyb
-- 暂停界面

UIPause = class("UIPause", function()
    return cc.Layer:create();
end);

function UIPause.create()
    return UIPause.new();
end

-- 构造函数
function UIPause:ctor()
    self:setName("UIPause");
    self:setLocalZOrder(10000000);

    local w = AlignM.frameSize.width;
    local h = AlignM.frameSize.height;

    local layout = ccui.Layout:create();
    layout:setBackGroundColorType(ccui.LayoutBackGroundColorType.solid);
    layout:setBackGroundColor(cc.c3b(0, 0, 0));
    layout:setContentSize(cc.size(w, h));
    layout:setOpacity(180);
    layout:setTouchEnabled(true);
    self:addChild(layout);

    local function onClick(sender, eventType)
        if eventType == ccui.TouchEventType.ended then
            self:removeFromParent();
        end
    end
    layout:addTouchEventListener(onClick);

    if isChromeBook() then
        -- --获取屏幕尺寸，初始化一个空的渲染纹理对象
        -- local winSize = cc.Director:getInstance():getWinSize()
        -- local target = cc.RenderTexture:create(winSize.width, winSize.height);
        -- target:beginWithClear(0, 0, 0, 255);
        -- cc.Director:getInstance():getRunningScene():visit();
        -- target:endToLua();

        -- local sprite = cc.Sprite:createWithTexture(target:getSprite():getTexture());
        -- sprite:setPosition(winSize.width / 2, winSize.height / 2);
        -- sprite:setFlippedY(true);
        -- layout:addChild(sprite);

        -- setBlurMode(sprite, true);
    end

    -- 暂停图案
    local imageView = ccui.ImageView:create();
    local iconPath  = "images/ui/common/play.png";
    imageView:loadTexture(iconPath);
    imageView:setPosition(w / 2, h / 2);
    imageView:setScale(w / 640);
    self:addChild(imageView);
end
